package com.gqj.meter.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.meter.domain.MdWarningInfo;
import com.gqj.meter.service.IMdWarningInfoService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 告警信息Controller
 *
 * @author lxq
 * @date lxq-02-10
 */
@Api(value = "/meter/mdWarningInfo", description = "报警信息")
@RestController
@RequestMapping("/meter/mdWarningInfo")
public class MdWarningInfoController extends BaseController
{
    @Autowired
    private IMdWarningInfoService mdWarningInfoService;

    /**
     * 查询告警信息列表
     */
    @ApiOperation("查询告警信息列表")
    @PreAuthorize("@ss.hasPermi('meter:mdWarningInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MdWarningInfo mdWarningInfo)
    {
        startPage();
        List<MdWarningInfo> list = mdWarningInfoService.selectMdWarningInfoList(mdWarningInfo);
        return getDataTable(list);
    }

    /**
     * 导出告警信息列表
     */
    @PreAuthorize("@ss.hasPermi('meter:mdWarningInfo:export')")
    @Log(title = "告警信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdWarningInfo mdWarningInfo)
    {
        List<MdWarningInfo> list = mdWarningInfoService.selectMdWarningInfoList(mdWarningInfo);
        ExcelUtil<MdWarningInfo> util = new ExcelUtil<MdWarningInfo>(MdWarningInfo.class);
        util.exportExcel(response, list, "告警信息数据");
    }

    /**
     * 获取告警信息详细信息
     */
    @ApiOperation("获取告警信息详细信息")
    @PreAuthorize("@ss.hasPermi('meter:mdWarningInfo:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") Long warningId)
    {
        return success(mdWarningInfoService.selectMdWarningInfoByWarningId(warningId));
    }

    /**
     * 新增告警信息
     */
    @ApiOperation("新增告警信息")
    @PreAuthorize("@ss.hasPermi('meter:mdWarningInfo:add')")
    @Log(title = "告警信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdWarningInfo mdWarningInfo)
    {
        return toAjax(mdWarningInfoService.insertMdWarningInfo(mdWarningInfo));
    }

    /**
     * 修改告警信息
     */
    @ApiOperation("修改告警信息")
    @PreAuthorize("@ss.hasPermi('meter:mdWarningInfo:edit')")
    @Log(title = "告警信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MdWarningInfo mdWarningInfo)
    {
        return toAjax(mdWarningInfoService.updateMdWarningInfo(mdWarningInfo));
    }

    /**
     * 删除告警信息
     */
    @ApiOperation("删除告警信息")
    @PreAuthorize("@ss.hasPermi('meter:mdWarningInfo:remove')")
    @Log(title = "告警信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warningIds}")
    public AjaxResult remove(@PathVariable Long[] warningIds)
    {
        return toAjax(mdWarningInfoService.deleteMdWarningInfoByWarningIds(warningIds));
    }

    /**
     * 查询告警信息列表
     */
    @ApiOperation("报警数量查询")
    @PreAuthorize("@ss.hasPermi('meter:mdWarningInfo:mdWarningStatistics')")
    @GetMapping("/getWarningCounts")
    public AjaxResult getWarningCounts()
    {
        return success(mdWarningInfoService.getWarningCounts());
    }
}
